VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "cSDKLine"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'******************************************************************'
'*                                                                *'
'*                      TurboCAD for Windows                      *'
'*                   Copyright (c) 1993 - 2006                    *'
'*             International Microcomputer Software, Inc.         *'
'*                            (IMSI)                              *'
'*                      All rights reserved.                      *'
'*                                                                *'
'******************************************************************'
' This sample demostrates how to use PointSnapped event
Option Explicit
Const NUM_TOOLS = 2
Dim b_ToolMode As Integer

Const m_EventMaskMouse = imsiEventMouseDown + imsiEventMouseUp + imsiEventMouseMove + imsiEventBeforeRightClick + imsiEventBeforeDoubleClick + imsiEventPointSnapped
Const m_EventMaskApp = imsiEventBeforeExit + imsiEventDrawingNew + imsiEventDrawingOpen + imsiEventDrawingActivate + imsiEventDrawingDeactivate + imsiEventDrawingBeforeClose + imsiEventDrawingBeforeSave + imsiEventWindowResize + imsiEventWindowActivate + imsiEventWindowDeactivate + imsiEventSelectionChange + imsiEventCommandBarControlHit + imsiEventCommandBarControlStatus + imsiEventRunTool + imsiEventPointPick + imsiEventRectanglePick + imsiEventPolygonPick + imsiEventViewBeforeRedraw + imsiEventViewAfterRedraw + imsiEventVirtualIntersectionPick + imsiEventCommandBarControlDone + imsiEventDrop + imsiEventCancel + imsiEventUpdateUndo + imsiEventDrawingAfterSave

Const m_EventMask = m_EventMaskMouse + m_EventMaskApp



'Private m_ptcTool As Tool
Public Property Get Description() As String
    Description = "SDKLine tool example"
End Property
Public Function GetToolInfo(CommandNames As Variant, MenuCaptions As Variant, StatusPrompts As Variant, ToolTips As Variant, Enabled As Variant, WantsUpdates As Variant) As Long
    ReDim CommandNames(NUM_TOOLS)
    ReDim MenuCaptions(NUM_TOOLS, 2)
    ReDim StatusPrompts(NUM_TOOLS)
    ReDim ToolTips(NUM_TOOLS)
    ReDim Enabled(NUM_TOOLS)
    ReDim WantsUpdates(NUM_TOOLS)
    Dim sICmd As String
    
    CommandNames(0) = "SDK|SDK Line "
    MenuCaptions(0, 0) = "&SDK Line"
    MenuCaptions(0, 1) = "SDK Line" ' toolbar name
    StatusPrompts(0) = "SDK Line"
    ToolTips(0) = "SDK Line"
    Enabled(0) = True
    WantsUpdates(0) = False
    
    CommandNames(1) = "SDK|SDK PolyLine "
    MenuCaptions(1, 0) = "&SDK PolyLine"
    MenuCaptions(1, 1) = "SDK Line" ' toolbar name
    StatusPrompts(1) = "SDK PolyLine"
    ToolTips(1) = "SDK PolyLine"
    Enabled(1) = True
    WantsUpdates(1) = False
    
    
    GetToolInfo = NUM_TOOLS
End Function


Public Function UpdateToolStatus(ByVal Tool As Tool, Enabled As Boolean, Checked As Boolean) As Boolean
    Enabled = True
    Checked = False
    
    Select Case Tool.Index
        Case 0
            If (m_bRun(0) = True) Then
                Checked = True
            End If
        Case 1
            If (m_bRun(1) = True) Then
                Checked = True
            End If
    End Select
    
    UpdateToolStatus = True
End Function

Public Function GetPicture(ByVal LargeImage As Boolean, ByVal MonoImage As Boolean) As Object
    On Error GoTo PictureError

    Dim TheImage As New StdPicture
    If GetButtonPicture(LargeImage, MonoImage, TheImage) Then
        Set GetPicture = TheImage
        Exit Function
    End If

PictureError:
    Set GetPicture = Nothing
End Function
Private Function GetButtonPicture(ByVal LargeImage As Boolean, ByVal MonoImage As Boolean, TheImage As StdPicture) As Boolean
    On Error GoTo ErrorHandler

    'There are two ways to load images:  from .Bmp file(s) or from .RES resource.
    'In this demo, we control the loading by a private variable.
    'Note that if you are loading from .Bmp, or if you are running this tool as a
    '.VBP for debugging, you must place the .Res or .Bmp files in the Draggers subdirectory
    'of the directory in which TCW11.EXE (or IMSIGX.DLL) is located.

        'Load from .Res file
    Dim idBitmap%  'BITMAP resource id in .Res file
    If LargeImage Then
        idBitmap% = 101
    Else
        idBitmap% = 102 '101
    End If
    Set TheImage = LoadResPicture(idBitmap%, vbResBitmap)
    GetButtonPicture = True
    Exit Function

ErrorHandler:
    GetButtonPicture = False
End Function
Public Function Initialize(ByVal Tool As Tool) As Boolean
    On Error GoTo ErrorHandler
    ReDim m_bRun(NUM_TOOLS)
    Dim i As Long
    
'    Set m_tcApp = Tool.Application
'    Set m_theToolEvents = m_tcApp 'Tool.Application
    b_ToolMode = 0
    'm_bRun = False
    For i = 0 To UBound(m_bRun)
        m_bRun(i) = False
    Next i
    
    m_iConnectId = 0
    ghHook = 0
    Initialize = True
    Exit Function
ErrorHandler:
    MsgBox "Method Initialize of " & Tool.Name & " tool failed " & Err.Description
    
End Function
Public Function Run(ByVal theTool As Tool) As Boolean
    Dim i As Long
    On Error GoTo ErrorHandler
    If m_tcApp Is Nothing Then
        Set m_tcApp = theTool.Application
        If m_theToolEvents Is Nothing Then
            Set m_theToolEvents = m_tcApp
        End If
    End If
    m_lLineColor = 0
' add local menu for our tool
    Set m_ptcTool = theTool
    ghHook = 0
    For i = 0 To UBound(m_bRun)
        m_bRun(i) = False
    Next i
    m_bRun(theTool.Index) = True
    ' we suppose that number of tools and number of members SDKLineTools enum are equal
    ' if you change number of tools please change SDKLineTools enum accordanly
    
    Select Case m_ptcTool.Index
            Case SDKLineTools.SDKLine
                Set T = New tcEventsHandler
                m_iConnectId = m_tcApp.ConnectEvents(T, m_EventMask)
                m_theToolEvents.ToolChangePrompt Me, "SDKLine Tool", False
                SDKLineToolAddLocalMenu True
            
            Case SDKLineTools.SDKPolyline
                m_bRun(theTool.Index) = False
                Set m_theToolEvents = Nothing
                MsgBox "Add your code here."
    End Select
    m_ActiveTool = theTool.Index
    Exit Function
ErrorHandler:
    MsgBox "Method run of " & theTool.Name & " tool failed " & Err.Description
End Function




